<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /* 事件循环机制
        先执行同步 再执行异步任务 包括（微任务 宏任务）  先执行微任务 再执行宏任务
        
        */
       console.log(0)
       let p1 = new Promise((resolve,reject)=>{
        //同步
           console.log('sunwei')
           if(true){
               console.log('jiaoziyang');
               resolve('1');
           }else{
               reject("2");
           }

       })
       setTimeout(()=>{
           console.log('xx');
       },0)
       p1.then(data=>{
           console.log(data)
           console.log('zihao');
       })
       p1.catch(err=>console.log(err));
       console.log('xuecheng');     //0 xuecheng zihao 
    </script>
</body>
</html>